//添加购物车
function addCat(id) {
    let num = $("#buyNum").val();
    if (num == "" || num == null) {
        num = 1;
    }
    $.post("/goods/addCat", {opr: "add", num: num, id: id}, function (data) {
        showMessage(data);
        showcat();
    }, "text");
}

//刷新购物车页面
function showcat() {
    $.post("/goods/addCat", {opr: "show"}, function (data) {
        $("#searchBar").html(data);
    })
}

function settlement1() {
    $.post("/goods/addCat", {opr: "set1"}, function (data) {
        $("#searchBar").html(data);
    })
}

function settlement2() {
    $.post("/goods/addCat", {opr: "set2"}, function (data) {
        $("#searchBar").html(data);
    })
}

function settlement3() {
    if ($(".selectAddress:checked").length > 0) {
        if ($("#aa:checked").length == 1) {
            let address = $("#address").val();
            let remark = $("#remark").val();
            if (address == "" || remark == "") {
                alert("请填写地址信息!");
            } else {
                $.post("/user/address", {address: address, remark: remark}, function (data) {
                    if (data == "true") {
                        $.post("/goods/addCat", {opr: "set3", address: address}, function (data) {
                            $("#searchBar").html(data);
                        })
                    }
                })
            }
        } else {
            var address = $(".selectAddress:checked").val();
            $.post("/goods/addCat", {opr: "set3", address: address}, function (data) {
                $("#searchBar").html(data);
            })
        }
    } else {
        alert("请选择地址");
    }


}